<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,auto-complete,dtvalidate,layui,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>
<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <!-- START 右侧数据 -->
            <div class="ibox float-e-margins" style="margin-bottom: 0px;">
                <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                    <form id="search-form" role="form" class="form-horizontal" autocomplete="off">
                        <div class="form-group">
                            <label class="control-label col-sm-1" >柜号:</label>
                            <div class="col-sm-2">
                                <input type="text" name="createPlanNo" id="createPlanNo" placeholder="请输入柜号" class="form-control" >
                            </div>
                            <label class="control-label col-sm-1" >供应商:</label>
                            <div class="col-sm-2">
                                <input type="text" name="supplierName" id="supplierName" placeholder="请填写供应商简称" class="form-control" >
                            </div>
                            <label class="control-label col-sm-1" >异常原因:</label>
                            <div class="col-sm-2">
                                <select  name="unusualReason" id="unusualReason" class="form-control">
                                    <option value="">全部分类</option>
                                    <%for(var dict in unusual){%>
                                    <option value="${dict.detailName}"  >${dict.detailName}</option>
                                    <%}%>
                                </select>
                            </div>
                            <label class="control-label col-sm-1" >状态:</label>
                            <div class="col-sm-1">
                                <select  name="flag" id="flag" class="form-control">
                                    <option value="">请选择</option>
                                    <option value="3">未付款</option>
                                    <option value="2">已付款</option>
                                </select>
                            </div>
                            <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                        </div>
                    </form>
                </div>
            </div>
            <!-- START 操作按钮 -->
            <form>
                <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                    <a class="add-btn btn btn-sm btn-success"><i class="fa fa-plus" aria-hidden="true"></i> 新增</a>
                    <button class="export-btn layui-btn  layui-btn-sm" style="margin-top: -6px;margin-left: -4px">
                        <i class="fa fa-download" aria-hidden="true"></i> 导出当前数据
                    </button>
                </div>
            </form>
            <!-- END 操作按钮 -->

            <!-- START 数据表格 -->
            <table id="resourceRecordTable"
                   data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-side-pagination="server"
                   data-url="/sea/physical/unusual/findByCnd.do"
                   data-page-size="15"
                   class="table table-striped table-hover">
            </table>
            <!-- END 数据表格 -->

            <!-- END 右侧数据 -->
        </div>
    </div>
</div>


<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer'}){}%>
<script>
    var $wareTable = $('#resourceRecordTable');

    $(function () {

        // START 表格配置
        $wareTable.bootstrapTable({
            pageSize:10,
            columns: [
                {
                    title: '柜号',
                    field: 'createPlanNo',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '供应商',
                    field: 'supplierName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '异常原因',
                    field: 'unusualReason',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '币种',
                    field: 'unusualMoneyType',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '费用',
                    field: 'unusualMoneyOriginal',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '实际装柜时间',
                    field: 'unusualTime',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '操作人',
                    field: 'operateName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '备注',
                    field: 'operateRemark',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '状态',
                    field: 'flag',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if(v==2){
                            return '已付款';
                        }else{
                            return '未付款';
                        }
                    }
                },
                {
                    field: 'operate',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){

                //删除
                $('.del-btn').on('click',function(){
                    var delid = $(this).attr('data-val')
                    layer.confirm('确定要删除当前？', {
                        btn: ['确定','取消'],title:'提示'
                    }, function(){
                        $.post('/sea/physical/unusual/delete.do',{id: delid},function(data){
                            if( data.ok ){
                                layer.msg(data.msg,{icon: 1,time: 1500},function(){
                                    //刷新页面
                                    $wareTable.bootstrapTable('refresh');
                                });
                            }else{
                                layer.msg(data.msg,{icon: 0,time: 1500});
                            }
                        });
                    });
                });
            }
        });


        //操作菜单
        function optFormatter(value,row){
            var content = '';
            if(row.flag==0) {
                content += '<button class="del-btn btn btn-xs btn-danger" data-val="' + row.id + '" title="删除"><i class="fa fa-trash-o"></i>  </button>';
            }
            return content;
        }
    });
    // 条件查询
    $('.search-btn').on('click',function () {
        $wareTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/physical/unusual/findByCnd.do?'+$('#search-form').serialize() });
    });
    //导出数据
    $(".export-btn").click(function () {
        window.location.href='/sea/physical/unusual/export.do?'+$('#search-form').serialize();
    });

    //新增
    $('.add-btn').on('click',function(){//新增
        layer.open({
            title: false,
            closeBtn: 0,
            type: 2,
            area: ['100%','100%'],
            skin: 'layer-ext-espresso',
            content: ['/sea/physical/unusual/addpage.do', 'yes']
        });
    });
</script>
</body>
</html>